package com.apestech.framework.run.core;

import java.sql.Connection;
import java.sql.SQLException;
import java.sql.Savepoint;

import com.alibaba.druid.pool.DruidDataSource;
import com.apestech.framework.db.SqlSession;
import com.apestech.framework.util.DBUtil;

public class DBExec {
	
	private Connection conn;
	private SqlSession session=null;
	
	public DBExec(DruidDataSource datasource) throws Exception{
		this.session= DBUtil.getSession(datasource);
	}

	public SqlSession getSession(){
		return this.session;
	}
	
	public void setAutoCommit(boolean arg0) throws SQLException{
		this.conn.setAutoCommit(arg0);
	}
	
	public void rollback() throws SQLException{
		this.conn.rollback();
	}
	
	public void rollback(Savepoint arg0) throws SQLException{
		this.conn.rollback(arg0);
	}
	
	public void commit() throws SQLException{
		this.conn.commit();
	}
	
	public void close() throws SQLException{
		this.conn.close();
	}

}
